package com.example.dormitorysystem.mapper;

import com.example.dormitorysystem.entity.GroupsUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.dormitorysystem.entity.Users;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 吉吉王国组
 * @since 2022-11-26
 */
public interface GroupsUserMapper extends BaseMapper<GroupsUser> {

    @Select("SELECT * FROM users WHERE uid in (select uid from groups_user where group_id = #{id})")
    List<Users> selectRoommateByGroupId(@Param("id") Integer groupId);

    @Select("select * from groups_user where group_id = #{groupId}")
    List<GroupsUser> selectMemberByGroupId(@Param("groupId") Integer groupId);

    @Select("select * from groups_user where uid = #{uid}")
    GroupsUser selectOneByUid(@Param("uid") Integer uid);
}
